package com.redpack.redpost.struts.action.admin;

//import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.redpack.redpost.util.dao.*;
import com.redpack.redpost.util.to.*;



public class EditarFolioGuia extends Action{
	public ActionForward execute(
			ActionMapping mapping, 
			ActionForm form, 
			HttpServletRequest request, 
			HttpServletResponse response) throws Exception {
		
		boolean logginVal = generalUtil.isLoggedInAdmin(request);
		if(logginVal!=true){
			return mapping.findForward("noLogin") ;
		}
		

			String cve_servicio = "";
			cve_servicio = request.getParameter("cve_servicio");
			
			if(cve_servicio != "" && cve_servicio != null)
			{
				if(isNumeric(cve_servicio))
				{
					FolioSecuenciaServicioTo _FolioSecuencia = new FolioSecuenciaServicioTo();
					_FolioSecuencia = FolioServicioDao.getFolioSecuencia(Integer.parseInt(cve_servicio));
	
					request.setAttribute("cve_servicio", ""+_FolioSecuencia.getCve_servicio());
					request.setAttribute("limite_inferior", ""+  _FolioSecuencia.getLimite_inferior());
					request.setAttribute("limite_superior", ""+_FolioSecuencia.getLimite_superior());
			
					
					return mapping.findForward("successedit") ;
				}
				else
				{
					return mapping.findForward("ErrorGenerico") ;
				}
				
			}

		return mapping.findForward("ErrorGenerico") ;
		
	}
	
	
  private static boolean isNumeric(String cadena){
	    try 
	    {
		    Integer.parseInt(cadena);
		    return true;
	    } 
	    catch (NumberFormatException nfe){
	    	return false;
	    }
	    
	    }
}